# Maintainer: Konstantin Gizdov <arch at kge dot pw>
_pkgname='csexp'
pkgname="ocaml-${_pkgname}"
pkgver=1.5.1
pkgrel=5
pkgdesc="OCaml canonical S-expressions"
arch=(loong64 x86_64)
url="https://github.com/ocaml-dune/csexp"
license=('MIT')
makedepends=(dune)
depends=(glibc "ocaml>=4.14.0" ocaml-findlib ocaml-result)
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('b451f380786fda53998f77b1509422d58bb5a51518595e329f625fbf0ca67e597be0c9935de77a10a65216cb4b9ec91579ad51bdeee536795e142e014433d46b')

build() {
    cd "${srcdir}/${_pkgname}-${pkgver}"
    dune build -p csexp
}

package() {
    cd "${srcdir}/${_pkgname}-${pkgver}"
    dune install --destdir="${pkgdir}" --prefix "/usr" --libdir "/usr/lib/ocaml"

    install -dm755 "${pkgdir}/usr/share/"
    mv "${pkgdir}/usr/doc" "${pkgdir}/usr/share/"

    install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}"
    ln -s /usr/share/doc/csexp/LICENSE.md "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
